//
//@File    :	9.12_namesp.cpp
//@Time    :	2021/08/25 16:43:55
//@Auther  :	Sun Sheng
//@Contact :	970340843@qq.com
//@Desc    :	namespaces
//

#include <iostream>
#include "9.11_namsp.h"

namespace pers
{
    using std::cin;
    using std::cout;
    void getPerson(Person &rp)
    {
        cout << "Enter first name: ";
        cin >> rp.fname;
        cout << "Enter last name: ";
        cin >> rp.lname;
    }
    void showPerson(const Person &rp)
    {
        std::cout << rp.lname << ", " << rp.fname;
    }
}

namespace debts
{
    void getDebt(Debt &rd)
    {
        getPerson(rd.name);
        std::cout << "Enter debt: ";
        std::cin >> rd.amount;
    }
    void showDebt(const Debt &rd)
    {
        showPerson(rd.name);
        std::cout << ": $" << rd.amount << std::endl;
    }
    double sumDebts(const Debt &rd)
    {
        showPerson(rd.name);
        std::cout << ":$" << rd.amount << std::endl;
    }
    double sumDebts(const Debt ar[], int n)
    {
        double total = 0;
        for (int i = 0; i < n; i++)
        {
            total += ar[i].amount;
        }
        return total;
    }
}